<script>
	import initConfig from "./initConfig.js"
	export default {
		methods: {},
		computed: {},
		onLaunch() {
			let pra = plus.runtime.arguments || ''
			plus.runtime.arguments = null;
			plus.runtime.arguments = "";
			
			let params = pra.split('://')[1] || ''
			params = decodeURIComponent(params)
			params = params.split('#').find(item => item.indexOf('&') > -1) || ''
			plus.runtime.arguments = null;
			plus.runtime.arguments = "";
			if (params) {
				this.$store.commit('INIT_OTHER_LINK', params)
			}
			// 捕获软键盘高度，并实时写入
			uni.onKeyboardHeightChange(res => {
				this.$store.commit('UPDATE_KEYBOARD_HEIGHT', res.height)
				// 对tabbar页面存在输入框导致tabbar被软键盘顶起处理
				uni[`${ !res.height ? 'show' : 'hide' }TabBar`]({
					animation: false
				})
			})
			initConfig(this.$store)
			//设置竖屏
			// #ifdef APP-PLUS
			plus.screen.lockOrientation('portrait-primary');
			// var pinf = plus.push.getClientInfo();
			// var cid = pinf.clientid; //客户端标识
			// console.log('cid：' + cid);
			// plus.push.addEventListener(
			// 	'click',
			// 	(msg) => {
			// 		console.log('click', msg)
			// 	},
			// 	false
			// );
			// plus.push.addEventListener(
			// 	'receive',
			// 	(msg) => {
			// 		console.log('receive', msg)
			// 	},
			// 	false
			// );
			// #endif
		},
		onShow() {
			setTimeout(() => {
				let pra = plus.runtime.arguments || ''
				plus.runtime.arguments = null;
				plus.runtime.arguments = "";
				
				let params = pra.split('://')[1] || ''
				params = decodeURIComponent(params)
				params = params.split('#').find(item => item.indexOf('&') > -1) || ''
				
				if (params) {
					let { commit, state } = this.$store
					commit('INIT_OTHER_LINK', params)
					if (!this.isFirst) {
						commit('BEFORE_INTO_INDEX', 'blank')
					}
					commit('ONSHOW_FIRST', false)
				}
				console.log('App Show')
			}, 0)
		},
		onHide() {
			console.log('App Hide')
		}
	}
</script>

<style lang='scss'>
	/* #ifndef APP-PLUS-NVUE */
	/* 注意要写在第一行，同时给style标签加入lang="scss"属性 */
	@import "uview-ui/index.scss";
	@import './static/css/style.css';
	@import './static/css/u.css';
	
	/* 不显示滚动条 */
	::-webkit-scrollbar {
		display: none;
		width: 0 !important;
		height: 0 !important;
		-webkit-appearance: none;
		background: transparent;
		color: transparent;
	}
	 /deep/.uni-scroll-view {
	        background-color: #fff;
	        
	    }
	
	/deep/.uni-scroll-view::-webkit-scrollbar {
		/* 隐藏滚动条，但依旧具备可以滚动的功能 */
		display: none
	}
	.u-drawer-bottom,
	.u-mode-center-box {
		background: transparent
	}

	/* 初始化默认字体大小28rpx，颜色默认是333 */
	html,
	body {
		font-size: 28rpx;
		color: #333333
	}
	image {
		will-change: transform
	}

	/* 页面背景-淡灰色 */
	.page-container {
		min-height: 100vh;
		background-color: #F9F9F9;
	}

	/* 图片载入替代方案 */
	.image-wrapper {
		font-size: 0;
		background: #f3f3f3;
		border-radius: 4px;

		image {
			width: 100%;
			height: 100%;
			transition: .6s;
			opacity: 0;

			&.loaded {
				opacity: 1;
			}
		}
	}

	/* #ifdef H5 */
	uni-page-head {
		display: none;
	}

	/* #endif */

	/* 遮罩层z-index: 默认是992 */
	.mask {
		position: fixed;
		top: 0;
		left: 0;
		z-index: 992;
		width: 100vw;
		height: 100vh;
		background-color: rgba(0, 0, 0, .1);
	}

	/* 通用 */
	$position: top,
	right,
	bottom,
	left;


	@for $i from 1 to 100 {
		.u {

			/* 内边距 */
			&-p-#{$i} {
				padding: $i + rpx;
			}

			/* 外边距 */
			&-m-#{$i} {
				margin: $i + rpx;
			}

			/* 字号 */
			&-f-#{$i} {
				font-size: $i + rpx;
			}

			/* 行高 */
			&-lh-#{$i} {
				line-height: $i + rpx;
			}

			/* 头像 */
			&-radius-#{$i} {
				border-radius: $i + rpx;
				overflow: hidden;
				
				&image,
				image {
					overflow: hidden;
					border-radius: $i + rpx;
				}
			}
			&-avatar-#{$i} {
				width: $i + rpx;
				height: $i + rpx;
				background-color: #f9f9f9;
				@extend .u-radius-#{$i};
			}

			$p: (t, r, b, l);

			@each $a in $p {
				$b: index($p, $a);

				
				/* 内边距 */
				&-p-#{$a}-#{$i} {
					padding-#{nth($position, $b)}: $i + rpx;
				}

				/* 外边距 */
				&-m-#{$a}-#{$i} {
					margin-#{nth($position, $b)}: $i + rpx;
				}
			}
		}
	}

	$textposition: left,
	center,
	right;

	.u-text {
		@each $a in $textposition {
			&-#{$a} {
				text-align: $a;
			}
		}
	}

	/* 内容超出省略号 */
	@for $i from 1 to 5 {
		.linecamp-#{$i} {
			@if $i==1 {
				overflow: hidden;
				text-overflow: ellipsis;
				white-space: nowrap;
				word-break: keep-all
			}

			@if $i>1 {
				overflow: hidden;
				text-overflow: ellipsis;
				display: -webkit-box;
				-webkit-box-orient: vertical;
				-webkit-line-clamp: $i;
				word-wrap: break-word;
				word-break: break-all;
			}
		}
	}

	.font-bold {
		font-weight: bold;
	}

	.font-medio {
		font-weight: 600;
	}

	.nowrap {
		white-space: nowrap
	}

	.clear-flex {
		flex-shrink: 0
	}

	.u-status-bar {
		height: var(--status-bar-height);
	}

	.page-container {
		min-height: 100vh;
		background-color: #f5f5f5;
	}

	.t-line {
		text-decoration: line-through
	}

	.header {
		position: sticky;
		top: 0;
		left: 0;
		z-index: 10200;
		background: #FFFFFF;

		&-navbar {
			position: relative;
			padding: 0 38rpx;
			height: 98rpx
		}
	}

	.common-title {
		position: absolute;
		left: 50%;
		top: 50%;
		transform: translate(-50%, -50%);
		font-weight: 600;
	}

	.auto-img {
		width: 100%;
		height: 100%;
	}

	/* flex伸缩布局 */
	.flex {
		display: flex;

		&-baseline {
			@extend .flex;
			align-items: baseline;
		}

		&-center {
			@extend .flex;
			align-items: center;

			&-center {
				@extend .flex-center;
				justify-content: center;
			}

			&-around {
				@extend .flex-center;
				justify-content: space-around;
			}

			&-between {
				@extend .flex-center;
				justify-content: space-between;
			}
		}

		&-around {
			@extend .flex;
			justify-content: space-around;
		}

		&-between {
			@extend .flex;
			justify-content: space-between;
		}

		&-column {
			flex-direction: column;
		}
	}

	/* #endif */
</style>
